#ifndef TCPCLIENT_H
#define TCPCLIENT_H


#include <QtNetwork\QTcpSocket>
#include <QtNetwork\QHostAddress>
#include <QTimer>
#include <QDateTime>


class TcpClientThread : public QObject
{
    Q_OBJECT
public:
    TcpClientThread(QObject* parent = NULL);
    ~TcpClientThread();

	QString GetCorrectUnicode(const QByteArray &ba);
	void startConnect();


	//bool write(const QJsonDocument &json);
protected:
private:
    bool m_status;
    QHostAddress* m_serverIP;
    QTcpSocket* m_tcpSocket;
    QDateTime m_receivedTime;
    QDateTime m_checkTime;
    QTimer *m_checkStatusTimer;

	QTimer *m_reconnectTimer;
    const char* m_p;
	QDateTime m_updateTime;

	bool isConnected;
	//int x;

	QTimer* m_sendMsg;

signals:
    void sendReceivedData(unsigned char *buffer, int length);
	void signalRequest(QString strMsgSend, int orderType);


    public slots:
    void slotEnter();
    void slotConnected();
    void slotDisconnected();
    void dataReceived();
    void SlotHeartBeat();
	void SlotReconnect();
	void slotSendOrder(QString strMsgSend, int orderType);
	void SlotSendMsg();
};


#endif